const Router = require('koa-router')
const mainRouter = new Router()

const { routersLoader } = require('../util/index')


function loader(app){

    routersLoader(__dirname).then(subRouter =>{

      subRouter.forEach(item =>{
        mainRouter.use(item.routes(), item.allowedMethods())
      })
      
      app.use(mainRouter.routes(), mainRouter.allowedMethods())
      
    })
  
}


module.exports = loader